/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tesis.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import tesis.controller.util.ConvertBeanUtil;
import tesis.domain.Rol;
import tesis.domain.dto.RolDTO;
import tesis.service.RolService;
/**
 *
 * @author hugo
 */
  
@Controller(value="rolController")
@RequestMapping(value="/rol")
public class RolController {
     private final static Logger LOG=LoggerFactory.getLogger(RolController.class);
    @Inject 
    private RolService rolService;
    
//        @RequestMapping(method= RequestMethod.GET)
//        public String init(){
//            LOG.info("Procesando GET  para /seguridad");
//
//            return "seguridad/inicio";
//        }
//
//
        @RequestMapping(value="/roles",method= RequestMethod.GET)
        public String roles(Model model){
            RolDTO rolDTO=new RolDTO();
            LOG.info("Procesando GET  para /Roles");

            model.addAttribute("rolDTO", rolDTO);
            return "seguridad/roles";
        }
    
    @RequestMapping(value="/findRoles",method= RequestMethod.GET)
    @ResponseBody
    public Map findRoles(RolDTO rol){
       Map map=new HashMap();    
        LOG.info("Procesando GET para  /find");
        
        map.put("lstRolesDTO", rolService.find(rol));
        map.put("totalRecords", rolService.cantidadRoles(rol));
        map.put("startIndex", rol.getStartIndex());
        return map;
    }
    
    
    
}
